<template>
  <div class="toolbar">
    <!-- 文件操作区 -->
    <el-tooltip content="新建谱子" placement="bottom">
      <el-button circle @click="onNew"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-add'"></use></svg></el-button>
    </el-tooltip>
    <el-tooltip content="打开谱子" placement="bottom">
      <el-button circle @click="onOpen"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-folderopen'"></use></svg></el-button>
    </el-tooltip>
    <el-tooltip content="保存谱子" placement="bottom">
      <el-button circle @click="onSave"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-SAVE'"></use></svg></el-button>
    </el-tooltip>
    <el-divider direction="vertical" class="toolbar-divider" />
    <!-- 编辑操作区 -->
    <el-tooltip content="撤销" placement="bottom">
      <el-button circle @click="onUndo"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-undo'"></use></svg></el-button>
    </el-tooltip>
    <el-tooltip content="重做" placement="bottom">
      <el-button circle @click="onRedo"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-outline-redo'"></use></svg></el-button>
    </el-tooltip>
    <el-divider direction="vertical" class="toolbar-divider" />
    <!-- 播放操作区 -->
    <el-tooltip content="播放" placement="bottom">
      <el-button circle @click="onPlay"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-play'"></use></svg></el-button>
    </el-tooltip>
    <el-tooltip content="暂停" placement="bottom">
      <el-button circle @click="onStop"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-pause'"></use></svg></el-button>
    </el-tooltip>
    <el-divider direction="vertical" class="toolbar-divider" />
    <!-- 导出/打印区 -->
    <el-tooltip content="导出PDF" placement="bottom">
      <el-button circle @click="onExportPdf"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-Pdf'"></use></svg></el-button>
    </el-tooltip>
    <el-tooltip content="导出图片" placement="bottom">
      <el-button circle @click="onExportImage"><svg class="icon" aria-hidden="true"><use :xlink:href="'#icon-Image'"></use></svg></el-button>
    </el-tooltip>
  </div>
</template>
<script>
export default {
  name: 'Toolbar',
  methods: {
    onPlay() {
      this.$emit('play');
    },
    onStop() {
      this.$emit('stop');
    },
    onSave() {
      this.$emit('save');
    },
    onOpen() {
      this.$emit('open');
    },
    onUndo() {
      this.$emit('undo');
    },
    onRedo() {
      this.$emit('redo');
    },
    onNew() {
      this.$emit('new');
    },
    onExportPdf() {
      this.$emit('exportPdf');
    },
    onExportImage() {
      this.$emit('exportImage');
    }
  }
}
</script>
<style scoped>
.toolbar {
  width: 100%;
  background: var(--surface-color);
  box-shadow: var(--shadow-sm);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-divider {
  margin: 0 8px;
  height: 24px;
  background-color: var(--border-color);
}

.icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.el-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;

  &:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    border-color: transparent;
    transform: translateY(-1px);
  }

  &:active {
    transform: translateY(0);
  }

  .icon {
    font-size: 18px;
  }
}

/* 工具提示样式优化 */
:deep(.el-tooltip__popper) {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--text-primary);
  color: white;
  box-shadow: var(--shadow-md);
}
</style> 